Fix concurrent function stats drop race#46
Draft
NikolayS wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the pgstats side of BUG #19520, where a stale concurrent function/procedure call can create and drop a function stats entry for an already-dropped procedure OID while the DROP transaction is still in post-commit stats cleanup.
Before this change, the second drop of the same shared stats entry raised:
ERROR: trying to drop stats entry already dropped: kind=function ...When that ERROR happened after
RecordTransactionCommit(), xact abort handling escalated to:PANIC: cannot abort transaction ..., it was already committedThis patch makes duplicate drops of an already-dropped shared stats entry behave like "not freed yet" rather than ERRORing, so normal pgstat entry-ref GC can finish the cleanup. The stale function-call path also requests that GC when its stats drop cannot free immediately.
The test adds injection points to deterministically schedule the race:
CALL proc_test()resolves the procedure OID and waits before function stats initDROP PROCEDURE proc_test()waits in post-commit function stats cleanupValidation:
elog(ERROR)reproduces the original ERROR -> COMMIT-state abort warning -> PANIC path in the new isolation spec.meson setup build -Dinjection_points=true -Dcassert=trueninja -C buildmeson test -C build --suite setup --print-errorlogsenv PG_TEST_TIMEOUT_DEFAULT=60 meson test -C build 'injection_points/isolation' 'injection_points/regress' --print-errorlogs